#include <iostream>
#include <string>
#include <fstream>
#include "message.pb.h"
using namespace std;

int main()
{

    ifstream ifs("file", ios::in | ios::binary);
    if (!ifs.is_open())
    {
        return -1;
    }

    ifs.seekg(0, ios::end);
    int filesize = ifs.tellg();
    ifs.seekg(0, ios::beg);

    string buffer;
    buffer.resize(filesize);

    ifs.read(&buffer[0], filesize);

    demo::msg rperson1;
    demo::msg rperson2;
    rperson1.ParseFromString(buffer);
    rperson2.ParseFromString(buffer);

    cout << "Rperson1:" << endl;
    cout << "name:  " << rperson1.name() << endl;
    cout << "gender :" << rperson1.gender() << endl;
    cout << "id:    " << rperson1.id() << endl;
    cout << endl;
    cout << "Rperson2:" << endl;
    cout << "name:  " << rperson2.name() << endl;
    cout << "gender :" << rperson2.gender() << endl;
    cout << "id:    " << rperson2.id() << endl;

    ifs.close();

    return 0;
}
